<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.news.bean.Add_admin;"%>
<%@page import="com.news.dao.*" %>
<%@page import="com.news.dao.impl.*" %>
<%@page import="com.news.util.*" %>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
    <%! int perSize=5;%>
        <title>list</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
            function page(sender){
                try{
                    var url='PagerServlet?callback=?';
                    var curr=$("#curr").attr("value");
                    var frame='<tr id="result" bgcolor="#FFFFFF"><td height="25" align="center"><input name="id" type="hidden" id="col_1" value="col_1">col_2</td><td align="center"><input name="password" type="password" class="input" value="col_3" id="userpassword" size="15" dataType="Require"  msg="请填写您的新密码！"><font color="#FF0000">*</font></td><td align="center"><input name="Submit" type="button"  onclick="window.location=\'adminEdit.jsp?addAccount=col_2&password=col_3&id=col_1\'" value=" 修 改 "></td><td align="center"><a href="admin?admin=deluser&id=col_1" onClick="return confirm(\'确定要删除吗?\')">删除</a></td><td align="center">&nbsp;</td></tr>';
                    jQuery.getJSON(url,{
                        type : sender.value,
                        current : curr,
                        SQL : 'select * from add_admin',
                        perSize : <%=perSize%>,
                        frames : frame
                    }, function(data){
                        try{
                            var result=decodeURIComponent(data.sucess);
                            result=result.replace(/\+/g,' ');
                            $("tr[id='result']").remove();
                            $('#page').before(result);
                            $('#curr').attr({value:data.current});
                        }catch(err){
                            alert(err.message);
                        }
                    });
                }catch(err){
                    alert(err.message);
                }

            }
        </script>
    </head>

    <body>
        <form name="dataForm" id="dataForm" method="post" action="admin?admin=edituser">
            <table width="98%"  border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#F2F9FD">
                <tr bgcolor="#D2E8F6">
                    <td height="25" colspan="5">&nbsp;&nbsp;管理管理员 <font color="#FF0000">(特别提醒：不要把所有的用户全部删除，否则不能进入后台管理系统！)</font></td>
                </tr>
                <tr align="center" bgcolor="#FFFFFF">
                    <td width="100" height="25">用户名</td>
                    <td width="150">密码</td>
                    <td width="100">修改</td>
                    <td width="100">删除</td>
                    <td width="250">&nbsp;</td>
                </tr>

                <%
            int PageNo = 1;
            List<Add_admin> list = (List) request.getAttribute("list");
            if (list != null && list.size() > 0) {
                int i = 1;
                for (Add_admin add : list) {
                    if(i>perSize)break;
                    int bil = i + (PageNo - 1) * 3;
                %>

                <tr bgcolor="#FFFFFF" id="result">
                    <td height="25" align="center"><input name="id" type="hidden" id="<%=add.getId()%>" value="<%=add.getId()%>">
                    <%=add.getAccount_no()%></td>
                    <td align="center"><input name="password" type="password" class="input" value="<%=add.getPassword()%>" id="userpassword" size="15" dataType="Require"  msg="请填写您的新密码！">
                        <font color="#FF0000">*</font></td>
                    <td align="center"><input name="Submit" type="button"  onclick="window.location='adminEdit.jsp?addAccount=<%=add.getAccount_no()%>&password=<%=add.getPassword()%>&id=<%=add.getId()%>'" value=" 修 改 "></td>
                    <td align="center"><a href="admin?admin=deluser&id=<%=add.getId()%>" onClick="return confirm('确定要删除吗?')">删除</a></td>
                    <td align="center">&nbsp;</td>
                </tr>
                <%
                    i++;%>
                <%
                }

            }%>
                <tr bgcolor="#FFFFFF" align="center" id="page">
                    <td><input type="hidden" name="curr" id="curr" value="0" /><input type="button" value="首页" onclick="page(this)"></td>
                    <td><input type="button" value="上一页" onclick="page(this)"></td>
                    <td><input type="button" value="下一页" onclick="page(this)"></td>
                    <td><input type="button" value="尾页" onclick="page(this)"></td>
                </tr>
            </table>
        </form>
    </body>
</html>
